package com.mccrea.principle.single;

/**
 * @Classname SingleResponsibility2
 * @Description 单一原则案例二
 *              分析：遵守单一职责原则，但是改的较大，需要修改客户端
 *              改进：直接修改Vehicle类
 * @Date 2021/5/6 0006 12:42
 * @Created by Mccrea_Gao
 * @see com.mccrea.principle.single.SingleResponsibility3
 */
public class SingleResponsibility2 {
    public static void main(String[] args) {
        RoadVehicle roadVehicle = new RoadVehicle();
        roadVehicle.run("SUV");
        roadVehicle.run("汽车");
        AirVehicle airVehicle = new AirVehicle();
        airVehicle.run("飞机");
        WaterVehicle waterVehicle = new WaterVehicle();
        waterVehicle.run("轮船");
    }
}

class RoadVehicle {
    public void run(String vehicle) {
        System.out.println(vehicle + "在公路运行");
    }
}

class AirVehicle {
    public void run(String vehicle) {
        System.out.println(vehicle + "在空中运行");
    }
}

class WaterVehicle {
    public void run(String vehicle) {
        System.out.println(vehicle + "在水中运行");
    }
}
